package com.ddtech.business.web.controller;

import com.ddtech.business.web.query.WebUserQuery;
import com.ddtech.business.web.res.UserTeacherRelVo;
import com.ddtech.business.web.service.WebUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author bin
 */
@Api(tags = "业务-业务用户")
@RestController
@RequestMapping("/web/user")
public class WebUserController {
    @Autowired
    private WebUserService webUserService;

    @ApiOperation(value = "分页查询用户列表")
    @GetMapping(value = "/page-list")
    public ResponseEntity getPageList(WebUserQuery webUserQuery) {
        return new ResponseEntity(webUserService.pageList(webUserQuery), HttpStatus.OK);
    }

    @ApiOperation(value = "POST方式查询")
    @PostMapping(value = "/page-list")
    public ResponseEntity getPostPageList(@RequestBody WebUserQuery webUserQuery) {
        return new ResponseEntity(webUserService.pageList(webUserQuery), HttpStatus.OK);
    }

    @ApiOperation(value = "分页学员导师关系列表")
    @GetMapping(value = "/page-list-rel")
    public ResponseEntity getListRel(WebUserQuery webUserQuery) {
        return new ResponseEntity(webUserService.getListRel(webUserQuery), HttpStatus.OK);
    }

    @ApiOperation(value = "创建导师学员关系")
    @PostMapping(value = "/create-rel")
    public ResponseEntity createRel(@Validated @RequestBody UserTeacherRelVo userTeacherRelVo) {
        webUserService.createRel(userTeacherRelVo);
        return new ResponseEntity( HttpStatus.OK);
    }
}
